﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    internal class OfficeArtBlipWMF : OfficeArtHeaderedBlip //\\meta
    {
        private WmfFormat _nativeFormat;

        public OfficeArtBlipWMF(byte[] data) : base(data)
        {
            NativeFormat = WmfFormat.One;
        }

        public OfficeArtBlipWMF()
        {
        }

        public override RecType RecordType
        {
            get { return RecType.OfficeArtBlipWMF; }
        }


        protected override string Extension
        {
            get { return "wmf"; }
        }

        protected override ushort Format
        {
            get { return (ushort) NativeFormat; }
            set { NativeFormat = (WmfFormat) value; }
        }

        protected WmfFormat NativeFormat
        {
            get {
                Contract.Ensures(Enum.IsDefined(typeof(WmfFormat), Contract.Result<WmfFormat>()));
                return _nativeFormat;
            }
            set {
                Contract.Requires(Enum.IsDefined(typeof(WmfFormat), value));
                _nativeFormat = value;
            }
        }

        protected override UidCount HasTwoIds()
        {
            switch (NativeFormat)
            {
                case WmfFormat.One: return UidCount.One;
                case WmfFormat.Two:return UidCount.Two;
                default:
                    throw new NotSupportedException();
            }
        }

        internal enum WmfFormat: ushort
        {
            One = 0x216,
            Two = 0x217,
        }
        internal override MSOBLIPTYPE Type
        {
            get { return MSOBLIPTYPE.msoblipWMF; }
        }
    }

    }